Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(objectContaining): Fixed a bug where ObjectContaining matched with non-object values. #15462

Closed

Conversation

mohammednumaan
Copy link
Contributor

Summary

The objectContaining method matches with non-object values, which is inconsistent. Thanks to @flovouin for finding this bug!

This PR fixes: #15420

This PR does the following:

  • Adds a conditional/check to ensure the argument passed to expect is an object.
  • Write new unit tests to ensure that new code does not break and works as intended.
  • Removes invalid test cases for the above bug.
  • Adds a few comments to clarify some bits of code.

Test plan

This is the new code I wrote for the objectContaining implementation:

image

This is the new test cases I wrote for verifying the above added code works:

image

To run the tests, I ran the following command:

yarn jest /packages/expect/src/__tests__/

The test results:

image

Copy link

netlify bot commented Jan 16, 2025

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit e9ee49b
🔍 Latest deploy log https://app.netlify.com/sites/jestjs/deploys/6789ed672900530008289bae
😎 Deploy Preview https://deploy-preview-15462--jestjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mohammednumaan mohammednumaan force-pushed the fix_object_containing_bug branch from ff0d770 to 569ba43 Compare January 17, 2025 05:38
@mohammednumaan mohammednumaan deleted the fix_object_containing_bug branch January 17, 2025 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: objectContaining matches non-object values
7 participants